package com.ss.android.article.base.feature.detail2.article.b;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.webkit.WebChromeClient;
import android.webkit.WebView;

import com.bytedance.article.common.c.TTUtils;
import com.bytedance.common.utility.Logger;
import com.bytedance.frameworks.base.mvp.Interactor;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.b.DBHelper;
import com.ss.android.article.base.feature.app.e.TTAndroidObject;
import com.ss.android.article.base.feature.detail.model.ArticleInfo;
import com.ss.android.article.base.feature.detail.view.DetailWebChromeClient;
import com.ss.android.article.base.feature.detail.view.MyWebViewClient;
import com.ss.android.article.base.feature.detail.view.MyWebViewClientV11;
import com.ss.android.article.base.feature.detail2.ArticleDetailWebPage;
import com.ss.android.article.base.feature.detail2.article.a.NewDetailViewHolder;
import com.ss.android.article.base.feature.detail2.article.c.NewDetailView;
import com.ss.android.article.base.feature.detail2.c.NewArticleDetailTTAndroidObject;
import com.ss.android.article.base.feature.detail2.d.DetailLoadResultHandler;
import com.ss.android.article.base.feature.detail2.d.NewDetailContext;
import com.ss.android.article.base.feature.model.Article;
import com.ss.android.article.base.feature.pgc.PgcActivity;
import com.ss.android.article.base.feature.video.MediaHelper;
import com.ss.android.article.browser.R;
import com.ss.android.common.dialog.AlertDialog;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.util.LoadUrlUtils;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.image.model.ImageInfo;
import com.ss.android.newmedia.a.AdsAppBaseActivity;
import com.ss.android.newmedia.e.JsObject.ContextDataProvider;
import com.ss.android.newmedia.e.JsObject.GalleryDisplayer;
import com.ss.android.newmedia.f.Response;
import com.ss.android.newmedia.util.AppUtil;
import com.ss.android.newmedia.webview.SSWebSettings;

import org.json.JSONException;
import org.json.JSONObject;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

public class DetailWebInteractor extends Interactor implements ArticleDetailWebPage, ContextDataProvider, GalleryDisplayer {
    public NewDetailContext mNewDetailContext;
    AppData mAppData;
    public NewDetailViewHolder mNewDetailViewHolder;
    public DetailLoadResultHandler mDetailLoadResultHandler;
    public NewArticleDetailTTAndroidObject mNewArticleDetailTTAndroidObject;
    public Response mResponse;
    public MyWebViewClient mMyWebViewClient;
    public DetailWebChromeClient mDetailWebChromeClient;
    public int j;
    private static final String TAG = DetailWebInteractor.class.getName();
    private DBHelper mDBHelper;
    private NewArticleDetailTTAndroidObject.WebListener mWebListener;

    public DetailWebInteractor(Context context,
                               NewDetailContext newDetailContext,
                               NewDetailViewHolder newDetailViewHolder,
                               DetailLoadResultHandler detailLoadResultHandler,
                               NewArticleDetailTTAndroidObject.WebListener webListener) {
        super(context);
        this.j = 0;
        this.mNewDetailContext = newDetailContext;
        this.mAppData = AppData.getInstance();
        this.mDBHelper = DBHelper.getInstance(context);
        this.mWebListener = webListener;
        this.mNewDetailViewHolder = newDetailViewHolder;
        this.mDetailLoadResultHandler = detailLoadResultHandler;
    }

    public final Response checkResponse(String arg4) {
        if (arg4 == null || mResponse == null || mResponse.originUrl == null) {
            return null;
        } else if (!AppUtil.a(arg4, mResponse.originUrl)) {
            return null;
        }
        return mResponse;
    }

    public final void onReceivedError(int errorCode, String description) {
        if (Logger.debug()) {
            Logger.v(TAG, "onReceivedError " + errorCode + " " + description);
        }

        if (this.hasView()) {
            if (mNewDetailViewHolder != null) {
                mNewDetailViewHolder.mWapStatHelper.onReceivedError(errorCode);
            }
        }
    }

    public final void onCreate(Bundle extraBundle, Bundle savedBundle) {
        super.onCreate(extraBundle, savedBundle);
        this.mMyWebViewClient = new MyWebViewClientV11(this);
        if (((NewDetailView) this.getView()).getFragment() != null) {
            this.mDetailWebChromeClient = new DetailWebChromeClient(((NewDetailView) this.getView()).getFragment(), ((ArticleDetailWebPage) this));
        } else if ((this.mContext instanceof Activity)) {
            this.mDetailWebChromeClient = new DetailWebChromeClient((Activity) this.mContext, this);
        } else {
            throw new RuntimeException("DetailWebInteractor's context must be Activity for now.");
        }

        this.mNewArticleDetailTTAndroidObject = new NewArticleDetailTTAndroidObject(this.mAppData, ((Interactor) this).mContext);
        this.mNewArticleDetailTTAndroidObject.setWebView(this.mNewDetailViewHolder.mWebView);
        this.mNewArticleDetailTTAndroidObject.mGalleryDisplayer = this;
        this.mNewArticleDetailTTAndroidObject.mJsDataProvider = this;
        this.mNewArticleDetailTTAndroidObject.a(this.mWebListener);
        return;

    }

    public final void onShowCustomView(View view, WebChromeClient.CustomViewCallback customViewCallback) {
        if (this.hasView()) {
            ((NewDetailView) this.getView()).onShowCustomView(view, customViewCallback);
        }
    }

    public final void onProgressChanged(WebView webView, int progress) {
        if (this.hasView()) {
            ((NewDetailView) this.getView()).onProgressChanged(webView, progress);
        }
    }

    public final void onPageStarted(WebView webView, String url) {
        boolean v0 = false;
        if (Logger.debug()) {
            Logger.v(TAG, "onPageStarted " + url + " " + webView.getOriginalUrl());
        }
        if (this.mNewDetailViewHolder != null) {
            this.mNewDetailViewHolder.l = false;
        }

        if (this.mNewDetailViewHolder != null && this.mNewDetailContext.article != null) {
            if (!this.mNewDetailViewHolder.isWebViewClientTransform()) {
                v0 = true;
            }
            if (url.startsWith("file:///android_asset/article/")) {
                this.mNewDetailViewHolder.mWapStatHelper.onPageStarted(webView, url, v0, url);
            } else {
                this.mNewDetailViewHolder.mWapStatHelper.onPageStarted(webView, url, v0, this.mNewDetailContext.article.articleUrl);
            }

            if (this.hasView()) {
                ((NewDetailView) this.getView()).onPageStarted(webView);
            }
        }
    }

    public final void queryContextData(String key, HashMap<String, Object> arg4) {
        if ("cid".equals(key)) {
            arg4.put(key, Long.valueOf(this.mNewDetailContext.adId));
        } else if ("log_extra".equals(key)) {
            arg4.put(key, this.mNewDetailContext.logExtra);
        }
    }

    public final void showLargeImage(List<ImageInfo> imageInfoList, int selectedIndex) {
        if (this.hasView()) {
            ((NewDetailView) this.getView()).startThumbPreviewActivity(imageInfoList, selectedIndex);
        }
    }

    public final void onHideCustomView() {
        if (this.hasView()) {
            ((NewDetailView) this.getView()).client_onHideCustomView();
        }
    }

    public final void onPageFinished(WebView webView, String url) {
        if (this.hasView()) {
            if (Logger.debug()) {
                Logger.v(TAG, "onPageFinished " + url);
            }

            if (url == null) {
                return;
            }

            if (url.equals("about:blank")) {
                return;
            }
            if (mNewDetailViewHolder == null) {
                return;
            }

            if (mNewDetailContext.article == null) {
                return;
            }

            int v1 = 0;
            int v0 = 0;
            String v2;
            if (url.startsWith("file:///android_asset/article/")) {
                mNewDetailViewHolder.l = true;
                v1 = 1;
                v0 = 1;
            } else if (TTUtils.isValidUrl(url)) {
                mNewDetailViewHolder.l = true;
                if (mNewDetailContext.article.hasArticleUrl()) {
                    v2 = webView.getOriginalUrl();
                    if (!AppUtil.a(mNewDetailContext.article.articleUrl, url) && !AppUtil.a(mNewDetailContext.article.articleUrl, v2)) {
                        if (this.mResponse != null && AppUtil.a(this.mResponse.requestUrl, url)) {
                            long now = System.currentTimeMillis();
                            mNewDetailContext.article.webTcLoadTime = now;
                            mNewDetailContext.article.webTypeLoadTime = now;
                            this.mDBHelper.saveWebLoadTime(mNewDetailContext.article.groupId, mNewDetailContext.article.itemId, now, true);
                            this.mDBHelper.saveWebLoadTime(mNewDetailContext.article.groupId, mNewDetailContext.article.itemId, now, false);
                            v1 = 1;
                        }
                    }
                }
            }

            if (this.mNewDetailContext.adId > 0 && webView != null && this.mAppData != null) {
                String js = SSWebSettings.buildAdJs(this.mAppData.jsActlogUrl, this.mNewDetailContext.adId);
                if (!android.support.design.a.isTextEmpty(js)) {
                    LoadUrlUtils.loadUrl(webView, js);
                }
            }

            this.mAppData.ae();
            this.mNewDetailContext.article.hasArticleUrl();
            mNewDetailViewHolder.mWapStatHelper.onPageFinished(webView, url);
            if (v0 != 0 || v1 != 0) {
                ArticleInfo articleInfo = this.mDetailLoadResultHandler.getArticleInfo(mNewDetailContext.article.groupId);
                long now = System.currentTimeMillis();
                if (articleInfo != null && now - articleInfo.d < 600000) {
                    if (articleInfo == null) {
                    } else if (mNewDetailViewHolder != null) {
                        boolean v2_1 = false;
                        String v4_1 = articleInfo.context;
                        if (v0 != 0 && !android.support.design.a.isTextEmpty(v4_1)) {
                            LoadUrlUtils.loadUrl(mNewDetailViewHolder.mWebView, "javascript:insertDiv(" + v4_1 + ")");
                            v2_1 = true;
                        }

                        boolean v0_3;
                        try {
                            if (android.support.design.a.isTextEmpty(articleInfo.script)) {
                                v0_3 = false;
                            } else {
                                v0_3 = true;
                                LoadUrlUtils.loadUrl(mNewDetailViewHolder.mWebView, "javascript:" + articleInfo.script);
                            }
                        } catch (Exception e) {
                            v0_3 = false;
                            Logger.w(TAG, "load info script exception: " + e);
                        }
                        if (Logger.debug()) {
                            Logger.v(TAG, "embedContextInfo " + this.mNewDetailContext.group_id + " " + v2_1 + " " + v0_3);
                        }
                    }
                } else {
                    if (NetworkUtils.isNetworkAvailable(this.mContext)) {
                        String itemKey = mNewDetailContext.article.getItemKey();
                        String fromWhere = this.mNewDetailContext.fromNotification ? "apn" : this.mNewDetailContext.detailSource;
                        mDetailLoadResultHandler.loadArticleInfo(itemKey, mNewDetailContext.article, fromWhere, new DetailLoadResultHandler.ResultListener() {

                            public final void onResult(Object arg2, Object arg3) {
                                if (DetailWebInteractor.this.hasView()) {
                                    ((NewDetailView) DetailWebInteractor.this.getView())
                                            .onArticleInfoLoaded(((Article) arg2), ((ArticleInfo) arg3));
                                }
                            }
                        });
                    }
                }
            }

            if (this.hasView()) {
                ((NewDetailView) this.getView()).d(url);
            }

            if (this.mResponse == null) {
                return;
            }

            if (TextUtils.isEmpty(this.mResponse.requestUrl)) {
                return;
            }

            if (this.mAppData.getAppSettings().disableDetail302Check()) {
                return;
            }

            LoadUrlUtils.loadUrl(this.mNewDetailViewHolder.mWebView, "javascript:window._toutiao_param_originUrl=\"" + this.mResponse.originUrl + "\"");
            LoadUrlUtils.loadUrl(this.mNewDetailViewHolder.mWebView, "javascript:window._toutiao_param_groupid=" + this.mNewDetailContext.group_id);
            LoadUrlUtils.loadUrl(this.mNewDetailViewHolder.mWebView, "javascript:window._toutiao_param_itemid=" + this.mNewDetailContext.item_id);
        }
    }

    public final TTAndroidObject getTTAndroidObject() {
        return this.mNewArticleDetailTTAndroidObject;
    }

    public final boolean shouldOverrideUrlLoading(WebView webView, String url) {
        boolean v2_8;
        NewDetailViewHolder v2_6;
        long v4_2;
        int v3_4;
        int v2_2 = 0;
        String v4_1;
        String v3_1;
        String scheme = null;
        Uri uri = null;
        if (!android.support.design.a.isTextEmpty(url) && (this.hasView())) {
            if (Logger.debug()) {
                Logger.v(TAG, "check url: " + System.currentTimeMillis() + " " + url);
            }

            try {
                uri = Uri.parse(url);
                scheme = uri.getScheme();
            } catch (Exception exception) {
                exception.printStackTrace();
            }

            if (uri != null && scheme != null) {
                if (scheme.equals("bytedance")) {
                    try {
                        uri = Uri.parse(url);
                    } catch (Exception exception) {
                    }

                    if (uri != null) {
                        String host = uri.getHost();
                        Article article = this.mNewDetailContext.article;
                        if ("domReady".equals(host)) {
                            if (this.mWebListener != null) {
                                this.mWebListener.onDomReady(webView);
                            }
                        } else if ("large_image".equals(host)) {
                            String imageUrl = uri.getQueryParameter("url");
                            String selectedIndexString = uri.getQueryParameter("index");
                            int selectedIndex = 0;
                            try {
                                selectedIndex = Integer.parseInt(selectedIndexString);
                            } catch (NumberFormatException numberFormatException) {
                            }

                            if (!android.support.design.a.isTextEmpty(imageUrl)) {
                                ArrayList<ImageInfo> imageInfoArrayList = new ArrayList();
                                if (this.mNewDetailContext.articleDetail != null && this.mNewDetailContext.articleDetail.imageDetail != null) {
                                    imageInfoArrayList.addAll(this.mNewDetailContext.articleDetail.imageDetail);
                                }

                                if ((imageInfoArrayList.isEmpty()) && (TTUtils.isValidUrl(imageUrl))) {
                                    imageInfoArrayList.add(new ImageInfo(imageUrl, null));
                                }

                                if (imageInfoArrayList.isEmpty()) {
                                    return true;
                                }

                                MobClickCombiner.onEvent(this.mContext, "image", "enter_detail");
                                if (!this.hasView()) {
                                    return true;
                                }
                                ((NewDetailView) this.getView()).startThumbPreviewActivity(imageInfoArrayList, selectedIndex);
                            }
                        } else {
                            if ("show_image".equals(host)) {
                                return true;
                            }

                            if ("video".equals(host)) {
                                String playUrl = uri.getQueryParameter("play_url");
                                String playJson = uri.getQueryParameter("json");
                                String refererUrl = webView.getUrl();
                                long groupId = article != null ? article.groupId : this.mNewDetailContext.group_id;
                                long itemId = article != null ? article.itemId : this.mNewDetailContext.item_id;
                                int aggrType = article != null ? article.aggrType : this.mNewDetailContext.aggrType;
                                Bundle bundle = null;
                                if (groupId > 0) {
                                    bundle = new Bundle();
                                    bundle.putLong("group_id", groupId);
                                    bundle.putLong("item_id", itemId);
                                    bundle.putInt("aggr_type", aggrType);
                                }

                                MediaHelper.startMediaPlayerActivity(this.mContext, playUrl, playJson, refererUrl, AppUtil.getUserAgent(this.mContext, webView), bundle);
                                JSONObject jsonObject = new JSONObject();
                                try {
                                    jsonObject.put("item_id", itemId);
                                    jsonObject.put("aggr_type", aggrType);
                                } catch (JSONException jsonException) {
                                }

                                MobClickCombiner.onEvent(this.mContext, "video", "play", groupId, 0, jsonObject);
                                return true;
                            }

                            if ("contentchanged".equals(host)) {
                                int webViewHeight = webView.getHeight();
                                int webViewContentHeight = webView.getContentHeight();
                                if (Logger.debug()) {
                                    Logger.d(TAG, "content changed " + url + " " + webViewHeight + " " + webViewContentHeight);
                                }
                                return true;
                            }

                            if (!"toggle_image".equals(host) && !"origin_image".equals(host)) {
                                if ("user_profile".equals(host)) {
                                    try {
                                        if (Long.parseLong(uri.getQueryParameter("user_id")) > 0) {
                                            AppData.aK();
                                        }
                                    } catch (Exception exception) {
                                        Logger.w(TAG, "url user_profile exception: " + url + " " + exception);
                                    }
                                } else if ("keywords".equals(host)) {
                                    try {
                                        String keyword = uri.getQueryParameter("keyword");
                                        if (!android.support.design.a.isTextEmpty(keyword)) {
                                            Intent intent = new Intent();
                                            intent.setClassName(this.mContext, "com.ss.android.article.base.feature.search.SearchActivity");
                                            intent.putExtra("keyword", keyword);
                                            intent.putExtra("from", "content");
                                            long groupId = 0L;
                                            long itemId = 0L;
                                            int aggrType = 0;
                                            if (mNewDetailContext.article != null) {
                                                groupId = mNewDetailContext.article.groupId;
                                                itemId = mNewDetailContext.article.itemId;
                                                aggrType = mNewDetailContext.article.aggrType;
                                            }

                                            intent.putExtra("group_id", groupId);
                                            intent.putExtra("item_id", itemId);
                                            intent.putExtra("aggr_type", aggrType);
                                            if (!this.hasView()) {
                                                return true;
                                            }
                                            ((NewDetailView) this.getView()).startActivity(intent);
                                        }
                                    } catch (Exception exception) {
                                        Logger.w(TAG, "url search excepton: " + url + " " + exception);
                                    }
                                } else {
                                    if ("media_account".equals(host)) {
                                        try {
                                            Long mediaId = Long.valueOf(Long.parseLong(uri.getQueryParameter("media_id")));
                                            String locString = uri.getQueryParameter("loc");
                                            int loc = 0;
                                            if (!android.support.design.a.isTextEmpty(locString)) {
                                                loc = Integer.parseInt(locString);
                                            }

                                            String enterFrom = loc > 0 ? "article_bottom_author" : "article_top_author";
                                            PgcActivity.startActivity(this.mContext, mediaId.longValue(), enterFrom);
                                        } catch (Exception exception) {
                                            Logger.w(TAG, "url pgc's media_account excepton: " + url + " " + exception);
                                        }

                                        return true;
                                    }

                                    if ("open_origin_url".equals(host)) {
                                        try {
                                            scheme = uri.getQueryParameter("url");
                                            if (!TTUtils.isValidUrl(scheme)) {
                                                return true;
                                            }

                                            this.e(webView, scheme);
                                        } catch (Exception v2_4) {
                                            Logger.w(TAG, "open_origin_url exception: " + url + " " + v2_4);
                                        }

                                        return true;
                                    }

                                    if ("article_impression".equals(host)) {
                                        try {
                                            v4_2 = android.support.design.a.x(uri.getQueryParameter("groupid"));
                                            long v6_1 = android.support.design.a.x(uri.getQueryParameter("item_id"));
                                            int aggrType = android.support.design.a.d(uri.getQueryParameter("aggr_type"), 0);
                                            if (article == null) {
                                                return true;
                                            }

                                            if (article.groupId <= 0) {
                                                return true;
                                            }

                                            if (v4_2 <= 0) {
                                                return true;
                                            }

                                            AppData.a(article.groupId, v4_2, v6_1, aggrType);
                                        } catch (Exception v2_4) {
                                        }

                                        return true;
                                    }

                                    if ("transcode_error".equals(host)) {
                                        v2_6 = this.mNewDetailViewHolder;
                                        if (v2_6 == null) {
                                            return true;
                                        }

                                        if (article == null) {
                                            return true;
                                        }

                                        if (article.delete) {
                                            return true;
                                        }

                                        if (!article.c()) {
                                            return true;
                                        }

                                        android.support.design.a.showImageToast(this.mContext, R.string.detail_transform_failed, R.drawable.close_popup_textpage);
                                        v2_6.mWebView.setTag(com.ss.android.article.browser.R.id.webview_transform_key, null);
                                        v2_6.mWebView.setTag(com.ss.android.article.browser.R.id.webview_client_transform_key, null);
                                        v2_6.mWebView.setTag(com.ss.android.article.browser.R.id.webview_support_js, null);
                                        return true;
                                    }

                                    if (this.mNewArticleDetailTTAndroidObject == null) {
                                        return true;
                                    }

                                    if (!NewArticleDetailTTAndroidObject.canHandleUri(uri)) {
                                        return true;
                                    }

                                    try {
                                        this.mNewArticleDetailTTAndroidObject.handleUri(uri);
                                    } catch (Exception v2_4) {
                                        Logger.w(TAG, "TTAndroidObj handleUri exception: " + v2_4);
                                    }
                                }

                                return true;
                            }

                            boolean v3_6 = this.mAppData.getAppSettings().isLargeImageDialogRepeatEnabled();
                            v2_2 = v3_6 ? 49 : 1;
                            int v4_3 = this.mAppData.clickShowLargeImageBtn;
                            if (!v3_6 || v4_3 != 19) {
                                if (v4_3 == v2_2) {
                                    v3_4 = 1;
                                } else {
                                    v3_4 = 0;
                                }
                            } else if (v4_3 == 1) {
                                v3_4 = 1;
                            } else if (v4_3 == 4) {
                                v3_4 = 1;
                            } else if (v4_3 == 9) {
                                v3_4 = 1;
                            } else {
                                v3_4 = 1;
                            }

                            if (v3_4 != 0) {
                                this.mAppData.setClickShowLargeImageBtn(v4_3 + 1);
                                AlertDialog.Builder v2_7 = com.ss.android.j.b.createDialogBuilder(this.mContext);
                                v2_7.setTitle(com.ss.android.article.browser.R.string.ss_hint);
                                v2_7.setMessage(com.ss.android.article.browser.R.string.detail_show_large_image_dlg);
                                v2_7.setPositiveButton(this.mContext.getString(com.ss.android.article.browser.R.string.ss_confirm), new DialogInterface.OnClickListener() {

                                    public final void onClick(DialogInterface arg3, int arg4) {
                                        mAppData.G();
                                        mAppData.setClickShowLargeImageBtn(50);
                                    }
                                });
                                v2_7.setNegativeButton(this.mContext.getString(com.ss.android.article.browser.R.string.ss_cancel), null);
                                v2_7.show();
                                return true;
                            }

                            if (v4_3 >= v2_2) {
                                return true;
                            }

                            this.mAppData.setClickShowLargeImageBtn(v4_3 + 1);
                        }

                        return true;
                    } else {
                        v2_8 = true;
                        return v2_8;
                    }
                } else {
                    if (TTUtils.isValidUrl(url)) {
                        webView.setTag(com.ss.android.article.browser.R.id.webview_client_transform_key, null);
                        webView.setTag(com.ss.android.article.browser.R.id.webview_transform_key, null);
                        webView.setTag(com.ss.android.article.browser.R.id.webview_support_js, null);
                        if (this.hasView()) {
                            ((NewDetailView) this.getView()).K();
                            ((NewDetailView) this.getView()).e(url);
                        }

                        v2_6 = this.mNewDetailViewHolder;
                        if (v2_6 != null) {
                            v2_6.mWapStatHelper.b(webView, url);
                        }

                        return false;
                    }

                    if (!scheme.equals("about") && !"about:blank".equals(url)) {
                        try {
                            if ((scheme.equals("sslocal")) || (scheme.equals("localsdk"))) {
                                url = AdsAppBaseActivity.b(url);
                            }

                            if (this.mAppData.i(url)) {
                                return true;
                            }

                            if ((this.mNewDetailContext.bundleForbidJump) && !com.ss.android.article.base.feature.app.a.c.b(scheme)) {
                                return true;
                            }

                            AppUtil.b(this.mContext, url);
                        } catch (Exception v2_4) {
                        }

                        return true;
                    }

                    webView.setTag(com.ss.android.article.browser.R.id.webview_transform_key, null);
                    return false;
                }
            }

            v2_8 = true;
        } else {
            v2_8 = true;
        }

        return v2_8;
    }

    public static boolean hasView(DetailWebInteractor detailWebInteractor) {
        return detailWebInteractor.hasView();
    }

    public final void doUpdateVisitedHistory(WebView webView, String url) {
        if (this.hasView()) {
            NewDetailViewHolder v0 = this.mNewDetailViewHolder;
            if (v0 != null && this.mNewDetailContext.article != null && this.mNewDetailContext.adId > 0) {
                v0.mWapStatHelper.c(webView, url);
            }
        }
    }

    public static com.bytedance.frameworks.base.mvp.View getView(DetailWebInteractor detailWebInteractor) {
        return detailWebInteractor.getView();
    }

    private void e(WebView arg7, String arg8) {
        int v1;
        int v0 = 0;
        try {
            if (Logger.debug()) {
                Logger.d(TAG, arg7.getUrl() + " " + arg8);
            }

            int[] v2 = this.mAppData.w;
            if (v2 != null && v2.length > 0) {
                int v3 = v2.length;
                v1 = 0;
                while (true) {
                    label_20:
                    if (v1 < v3) {
                        com.ss.android.newmedia.b.a v4 = android.support.design.a.d(v2[v1]);
                        if (v4 != null && (v4.a(((Interactor) this).mContext, arg8))) {
                            v0 = 1;
                        } else {
                            label_36:
                            ++v1;
                            continue;
                        }
                    }
                    break;
                }
            }
            if (v0 != 0) {
                return;
            }
            String v0_2 = arg7.getUrl();
            if (!TTUtils.isValidUrl(v0_2)) {
                v0_2 = null;
            }

            android.support.design.a.b(((Interactor) this).mContext, arg8, v0_2);
        } catch (Exception v0_1) {
            v0_1.printStackTrace();
        }
    }
}

